#include "glcs_glsl_code.h"

const char *g_glsl_host_to_device =
    "#version 320 es\n"
    "#define PRECISION highp\n"
    "precision PRECISION float;\n"
    "#define FORMAT rgba32f\n"
    "layout(FORMAT, binding=0) writeonly uniform PRECISION image3D uImage;\n"
    "layout(binding=1) readonly buffer SSBO {\n"
    "    float data[];\n"
    "} uInBuffer;\n"
    "layout(location = 2) uniform int uWidth;\n"
    "layout(location = 3) uniform int uHeight;\n"
    "layout(location = 4) uniform int uChannel;\n"
    "layout (local_size_x = 4, local_size_y = 4, local_size_z = 1) in;\n"
    "void main()\n"
    "{\n"
    "    ivec3 pos = ivec3(gl_GlobalInvocationID);\n"
    "    if (pos.x < uWidth && pos.y < uHeight)\n"
    "    {\n"
    "        vec4 color;\n"
    "        int z = pos.z*4;\n"
    "        color.r = uInBuffer.data[pos.y*uWidth*uChannel + pos.x*uChannel + (z+0)];\n"
    "        color.g = uInBuffer.data[pos.y*uWidth*uChannel + pos.x*uChannel + (z+1)];\n"
    "        color.b = uInBuffer.data[pos.y*uWidth*uChannel + pos.x*uChannel + (z+2)];\n"
    "        color.a = uInBuffer.data[pos.y*uWidth*uChannel + pos.x*uChannel + (z+3)];\n"
    "        imageStore(uImage, pos, color);\n"
    "    }\n"
    "}\n";

const char *g_glsl_device_to_host =
    "#version 320 es\n"
    "#define PRECISION highp\n"
    "precision PRECISION float;\n"
    "#define FORMAT rgba32f\n"
    "layout(FORMAT, binding=0) readonly uniform PRECISION image3D uImage;\n"
    "layout(binding=1) writeonly buffer destBuffer{\n"
    "    float data[];\n"
    "} uOutBuffer;\n"
    "layout(location = 2) uniform int uWidth;\n"
    "layout(location = 3) uniform int uHeight;\n"
    "layout(location = 4) uniform int uChannel;\n"
    "layout (local_size_x = 4, local_size_y = 4, local_size_z = 1) in;\n"
    "void main()\n"
    "{\n"
    "    ivec3 pos = ivec3(gl_GlobalInvocationID);\n"
    "    if (pos.x < uWidth && pos.y < uHeight)\n"
    "    {\n"
    "        vec4 color = imageLoad(uImage, pos);\n"
    "        int z = pos.z*4;\n"
    "        uOutBuffer.data[pos.y*uWidth*uChannel+pos.x*uChannel+(z+0)] = color.r;\n"
    "        uOutBuffer.data[pos.y*uWidth*uChannel+pos.x*uChannel+(z+1)] = color.g;\n"
    "        uOutBuffer.data[pos.y*uWidth*uChannel+pos.x*uChannel+(z+2)] = color.b;\n"
    "        uOutBuffer.data[pos.y*uWidth*uChannel+pos.x*uChannel+(z+3)] = color.a;\n"
    "    }\n"
    "}\n";
